﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using GoodMan.Infrastructure.Entities.Repository;

namespace GoodMan.Infrastructure.Entities.Entity
{
    public class Recommended : IAccessible<T_Recommended, Recommended>, ILogicEntity<T_Recommended, Recommended>
    {
        public int Id { get; set; }
        public int ProductId { get; set; }
        public string ProductName { get; set; }
        public DateTime CreateDate { get; set; }
        public string Creator { get; set; }

        public Product product { get; set; }

        public Recommended LoadProduct(T_Product product)
        {
            this.product = new Product().Set(product);
            return this;
        }

        protected override void Covariant(T_Recommended model)
        {
            if (model != null)
            {
                this.CreateDate = model.CreateDate;
                this.Creator = model.Creator;
                this.Id = model.Id;

                this.ProductId = model.ProductId;
                this.ProductName = model.ProductName;

            }
        }

        protected override T_Recommended Inverter(Recommended model)
        {
            if (model != null)
            {
                return new T_Recommended()
                {
                    CreateDate = model.CreateDate,
                    Creator = model.Creator,
                    Id = model.Id,
                    ProductId = model.ProductId,
                    ProductName = model.ProductName
                };
            }
            return null;
        }

        public Recommended Set(T_Recommended dbModel)
        {
            Covariant(dbModel);
            return this;
        }
    }
}
